home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / clipper / slsw.zip / SF.PRG < prev    next >
Text File  |  1990-10-04  |  20KB  |  664 lines

  1. *:*********************************************************************
  2. *:
  3. *:        Program: SF.PRG
  4. *:
  5. *:         System: Super.Lib Library for Clipper
  6. *:         Author: Garry Prefontaine
  7. *:      Copyright (c) 1989, Garry Prefontaine
  8. *:  Last modified: 12/12/89     11:27
  9. *:
  10. *:  Procs & Fncts: PAINT_SF()
  11. *:               : SF_SHOW()
  12. *:               : SF_PICKDBF()
  13. *:               : COPYITOUT()
  14. *:               : SF_APPEND()
  15. *:               : SF_PICKND()
  16. *:               : SF_ORDER()
  17. *:               : SF_OPENEM()
  18. *:               : PICK_NDX()
  19. *:
  20. *:          Calls: INITSUP()      (function in SUPER.LIB)
  21. *:               : CAPSLOCK()     (function in SUPER.LIB)
  22. *:               : PULLDN()       (function in SUPER.LIB)
  23. *:               : MSG()          (function in SUPER.LIB)
  24. *:               : MESSYN()       (function in SUPER.LIB)
  25. *:               : MODIS()        (function in SUPER.LIB)
  26. *:               : BLDNDX()       (function in SUPER.LIB)
  27. *:               : GLOBREP()      (function in SUPER.LIB)
  28. *:               : EDITDB()       (function in SUPER.LIB)
  29. *:               : DOITALL()      (function in SUPER.LIB)
  30. *:               : LISTER()       (function in SUPER.LIB)
  31. *:               : DUPLOOK()      (function in SUPER.LIB)
  32. *:               : CLABEL()       (function in SUPER.LIB)
  33. *:               : FORMLETR()     (function in SUPER.LIB)
  34. *:               : SUM_AVE()      (function in SUPER.LIB)
  35. *:               : OCCUR()        (function in SUPER.LIB)
  36. *:               : SETCOLORS()    (function in SUPER.LIB)
  37. *:               : INITCOL()      (function in SUPER.LIB)
  38. *:               : FULLDIR()      (function in SUPER.LIB)
  39. *:               : PAINT_SF()     (function  in SF.PRG)
  40. *:               : SF_SHOW()      (function  in SF.PRG)
  41. *:               : SF_PICKDBF()   (function  in SF.PRG)
  42. *:               : COPYITOUT()    (function  in SF.PRG)
  43. *:               : SF_APPEND()    (function  in SF.PRG)
  44. *:               : SF_PICKND()    (function  in SF.PRG)
  45. *:               : SF_ORDER()     (function  in SF.PRG)
  46. *:               : SF_OPENEM()    (function  in SF.PRG)
  47. *:
  48. *:      Documented 12/12/89 at 11:32                SNAP!  version 3.12e
  49. *:*********************************************************************
  50.  
  51. *- initialize metafunctions
  52. initsup()
  53.  
  54. *- define type of index
  55. defindex = '*'+Indexext()
  56.  
  57.  
  58. *- set caps on
  59. capslock(.T.)
  60.  
  61. *- initialize some variables
  62. isfopen = .F.
  63. STORE '' TO dbfname,ndx_string,query_exp
  64. ndx_order = 1
  65.  
  66. *- set some sets
  67. SET TALK OFF
  68. SET ECHO OFF
  69. SET CONFIRM OFF
  70. SET BELL OFF
  71. SET SAFETY OFF
  72. SET SCOREBOARD OFF
  73. SET TYPEAHEAD TO 50
  74. EXTERNAL kbd_escape
  75. EXTERNAL fastform
  76.  
  77. *- initialize SF arrays for holding
  78. *- indexes in current directory
  79. DECLARE sf_ndxs[adir(defindex)+1]
  80. *- active indexes
  81. DECLARE sf_acndx[6]
  82.  
  83.  
  84. *- set color
  85. Setcolor(c_normcol)
  86.  
  87.  
  88. *- draw the screen
  89. paint_sf()
  90.  
  91.  
  92. *- menu choice definitions
  93. PRIVATE choices[6]
  94. choices[1] = "Datafiles:Use Datafile:Define New Datafile:Modify Existing Datafile Definition:Copy records out:Append records in"
  95. choices[2] = "Indices:Select Indices:Index order:New Index"
  96. choices[3] = "Editing:Field Replacement:Tabular Edit:Vertical Edit"
  97. choices[4] = "Reporting:Build Query:Print Lists:Hunt Duplicates:Create Labels:Write Form Letters:Sum or Average a Field:Field Occurrance"
  98. choices[5] = "Other:List text file:Design Screen Appearance:Change Directory"
  99. choices[6] = "Quit:Quit:Author:Info"
  100. sf_sel = 1.01
  101.  
  102. *- define menu boxes
  103. PRIVATE boxdata[7]
  104. boxdata[1] = !(ISCOLOR())      && draw the top bar box ?
  105. boxdata[2] = m->c_normcol      && top bar color string
  106. boxdata[3] = m->c_popmenu      && drop box color
  107. boxdata[4] = m->c_frame        && drop box frame
  108. boxdata[5] = 3                 && drop box shadow position (1,3,7,9,0)
  109. boxdata[6] = m->c_shadatt      && drop box shadow attribute
  110. boxdata[7] = 0                 && row # of menu bar
  111.  
  112.  
  113. DO WHILE .T.
  114.    sf_show()                   && display dbfs and indexes
  115.    
  116.    
  117.    *- do the menu
  118.    sf_sel = pulldn(m->sf_sel,m->choices,m->boxdata)
  119.    
  120.    
  121.    *- if 0 returned, selection is QUIT
  122.    IF m->sf_sel = 0
  123.       m->sf_sel = 6.01
  124.    ENDIF
  125.    
  126.    
  127.    *- do the action corresponding to the menu choice
  128.    DO CASE
  129.    CASE m->sf_sel = 1.01     && select a DBF
  130.       
  131.       IF Adir('*.dbf') > 0
  132.          sf_pickdbf()
  133.       ELSE
  134.          msg("No DBFs detected in this directory")
  135.       ENDIF
  136.       
  137.       
  138.    CASE m->sf_sel = 1.02   && create structure
  139.       
  140.       IF messyn("Datafiles will be closed while defining new datafile","Continue","Quit",10,10)
  141.          modis("C")
  142.          CLOSE DATA
  143.          isfopen = .F.
  144.          dbfname = ''
  145.       ENDIF
  146.       
  147.       
  148.    CASE m->sf_sel = 1.03   && modify structure
  149.       IF messyn("Datafiles will be closed while modifying datafile","Continue","Quit",10,10)
  150.          modis("M")
  151.          CLOSE DATA
  152.          isfopen = .F.
  153.          dbfname = ''
  154.       ENDIF
  155.       
  156.       *- rest of options below 5 require dbf open
  157.    CASE m->sf_sel < 5  .AND. !m->isfopen
  158.       msg("Need a DBf open for this option")
  159.       
  160.       
  161.    CASE m->sf_sel = 1.04   && copy records out
  162.       copyitout()
  163.       
  164.    CASE m->sf_sel = 1.05   && append records in
  165.       sf_append()
  166.       
  167.    CASE m->sf_sel =2.01                && select indices
  168.       IF Adir(m->defindex) > 0
  169.          sf_picknd()
  170.       ENDIF
  171.       
  172.    CASE m->sf_sel = 2.02   .AND. !EMPTY(m->ndx_string)  && index order
  173.       
  174.       sf_order()          && change index order
  175.       
  176.    CASE m->sf_sel = 2.03        && make temp index
  177.       inname = bldndx()
  178.       IF !EMPTY(m->inname)
  179.          Ains(m->sf_acndx,1)    && insert in active index array
  180.          sf_acndx[1] = Alltrim(m->inname)+Indexext()
  181.          
  182.          sf_openem()            && reopen indexes
  183.          ndx_order = 1
  184.       ENDIF
  185.       
  186.    CASE m->sf_sel = 3.01            && global replace
  187.       globrep()
  188.       
  189.    CASE m->sf_sel = 3.02            && horizontal edit
  190.       editdb(.T.)
  191.       
  192.    CASE m->sf_sel = 3.03            && vertical edit
  193.       PRIVATE opts[2],procs[2]      && build arrays for 'Other' menu
  194.       opts[1]="Single Formletter"
  195.       opts[2]="Quit"
  196.       procs[1] = "FASTFORM"
  197.       procs[2] = ""
  198.       doitall(m->opts,m->procs)
  199.       
  200.    CASE m->sf_sel = 4.01            && query
  201.       query_exp = QUERY()
  202.       
  203.       
  204.    CASE m->sf_sel = 4.02            && print list
  205.       lister()
  206.       
  207.    CASE m->sf_sel = 4.03            && hunt duplicates
  208.       duplook()
  209.       
  210.       *- open index files again
  211.       sf_openem()
  212.       
  213.    CASE m->sf_sel = 4.04            && labels
  214.       clabel()
  215.       
  216.    CASE m->sf_sel = 4.05        && form letter
  217.       formletr()
  218.       
  219.    CASE m->sf_sel = 4.06     && sum/AVERAGE
  220.       IF messyn("Sum or Average?","Sum","Average")
  221.          sum_ave()
  222.       ELSE
  223.          sum_ave("AVE")
  224.       ENDIF
  225.       
  226.       
  227.    CASE m->sf_sel = 4.07    && occurance
  228.       occur()
  229.       
  230.    CASE m->sf_sel = 5.01    && list text file
  231.       Fileread()
  232.       
  233.       
  234.    CASE m->sf_sel = 5.02            && color setting
  235.       setcolors()
  236.       RESTORE FROM COLORS.MEM ADDIT
  237.       SET COLOR TO (m->c_normcol)
  238.       paint_sf()                    && repaint screen
  239.       
  240.       *- redefine menu box data
  241.       boxdata[1] = !(ISCOLOR())
  242.       boxdata[2] = m->c_normcol
  243.       boxdata[3] = m->c_popmenu
  244.       boxdata[4] = m->c_frame
  245.       boxdata[5] = m->c_shadpos
  246.       boxdata[6] = m->c_shadatt
  247.       boxdata[7] = 0
  248.       
  249.       
  250.    CASE m->sf_sel = 5.03  && dir picker
  251.       IF fulldir()
  252.          CLOSE DATA
  253.          isfopen = .F.
  254.          query_exp=''
  255.          paint_sf()
  256.       ENDIF
  257.       
  258.       
  259.    CASE m->sf_sel = 6.01            && quit
  260.       IF messyn('Are you sure?')
  261.          SET CURSOR ON
  262.          CLEAR
  263.          EXIT
  264.       ENDIF
  265.       
  266.    CASE m->sf_sel = 6.02
  267.       msg(" Super.Lib Library for Clipper","","Written by Garry A Prefontaine","920 N Washington","Edmond, Oklahoma, 73034","(405) 340-1940","Copyright (c) 1989, Garry A Prefontaine")
  268.       
  269.    CASE m->sf_sel =